package com.fertshop.gui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

import com.fertshop.dto.ShopDto;
import com.fertshop.gui.listener.AddShopMenuListener;
import com.fertshop.gui.listener.DeleteShopMenuListener;
import com.fertshop.gui.listener.SortShopNameMIActionListener;
import com.fertshop.gui.listener.SortSpAreaMIActionListener;
import com.fertshop.gui.listener.UpdateShopMenuListener;
public class Main{
	
	public static JFrame frame=new JFrame();
	public static ShopDto shopdto=null;
	public static ShopDto updatedto=null;
    public static JDesktopPane desktop;
	public static void main(String[] args) 	{		
		frame.addWindowListener(new WindowAdapter(){
			public void windowClosing(WindowEvent e){				
				System.exit(0);
			}
		});
		frame.setTitle("Fertilizer Shop License Management");
		frame.setBackground(Color.lightGray);
		desktop = new JDesktopPane();
		frame.setContentPane(desktop);		
		
		JMenuBar menubar=new JMenuBar();
		
		JMenu menu=new JMenu("Add Shop");
		menu.addMenuListener(new AddShopMenuListener(desktop));
		menubar.add(menu);
		
		JMenu updateShopmenu=new JMenu("Update Shop");
		updateShopmenu.addMenuListener(new UpdateShopMenuListener(desktop));
		menubar.add(updateShopmenu);
		
		JMenu deleteShopmenu=new JMenu("Delete Shop");
		deleteShopmenu.addMenuListener(new DeleteShopMenuListener());
		menubar.add(deleteShopmenu);
		
		JMenu viewAllShopmenu=new JMenu("View All Shops");
		//viewAllShopmenu.addMenuListener(new ViewAllShopsMenuListener(desktop));
		JMenuItem sortShopNameMI=new JMenuItem("Sort By Shop Name");
		sortShopNameMI.addActionListener(new SortShopNameMIActionListener(desktop));
		viewAllShopmenu.add(sortShopNameMI);
		JMenuItem sortSpAreaMI=new JMenuItem("Sort By Salepoint Area");
		sortSpAreaMI.addActionListener(new SortSpAreaMIActionListener(desktop));
		viewAllShopmenu.add(sortSpAreaMI);
		menubar.add(viewAllShopmenu);
		
		frame.setJMenuBar(menubar);
		
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		frame.setBounds(0,0,(screenSize.width-50),(screenSize.height-50));		
		frame.setVisible(true);
	}
}
